#include "mylabel.h"
#include <QTimer>
#include <QDebug>
MyLabel::MyLabel(QWidget *parent):
    QLabel(parent),
    downCount(3),
    timer(NULL)
{
    timer = new QTimer();
    connect(timer,&QTimer::timeout,this,&MyLabel::slotTimer);
    timer->setInterval(1000);
}

void MyLabel::slotTimer()
{
    setText(QString::number(downCount));
    --downCount;
    if(downCount < 0)
    {
        timer->stop();
        emit signalTheEnd();
    }
}


void MyLabel::setShow(bool isShow)
{
    if(isShow)
    {
        downCount = 3;
        timer->start();
        this->setVisible(true);
    }
    else
    {
        downCount = 3;
        timer->stop();
        this->setVisible(false);
    }
}
